#include <iostream>

#include "XrdDMSimulator.hh"
#include <stdlib.h>
#include <time.h>
using namespace std;

#include <XrddmConfig.h>

int main(int argc, char **argv)
{
  XrdDMSimSiteInfo *site;

  XrdDMSimulator simulator;
  simulator.SetTimeSeed();
  XrdDownloadManager *dm = simulator.GetDownloadManager();
//   dm->SetDebug(10);
  dm->DeleteServersFile();
  dm->UseServersFile();
  dm->UseServersFileTryNewSitesFirst();
  dm->UseFallbackDownload();


  site = simulator.AddSite("site01",100,200,50);
  site = simulator.AddSite("site02",5000,6000,10);
  site = simulator.AddSite("site03",4000,5000,10);
  site = simulator.AddSite("site04",100,200,50);
  site = simulator.AddSite("site05",5000,6000,10);
  site = simulator.AddSite("site06",4000,5000,10);

  simulator.GenerateFileCatalog(100,4);

  // has to be done after generate
  XrdDMSimFileCatalog *fc = simulator.GetFileCatalog();
  fc->SetNumberOfFilesNotStaged("site01");
//   fc->SetNumberOfFilesNotStaged("site02");
//   fc->SetNumberOfFilesNotStaged("site03");
//   fc->SetNumberOfFilesNotStaged("site04");
//   fc->SetNumberOfFilesNotStaged("site05");
//   fc->SetNumberOfFilesNotStaged("site06");
//   fc->Print();

  simulator.Simulate(10);
//   simulator.Print();


//   XrdDownloadManager dm("xrootd_servers.txt");
//   dm.ReadFile();
//   dm.WriteFile();
//   dm.Print(false);
//   cout << "Selected server is " << dm.GetServerName(2) << " on port " <<  dm.GetServerPort(2) << endl;
  return 0;
}
